import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ProductAttrApiService } from 'src/app/api/product-attr-api.service';
import { ProductAttribute } from 'src/app/model/productAttr';

@Injectable({
  providedIn: 'root'
})
export class ProductAttrDetialResolverService implements Resolve<ProductAttribute>{

  constructor(
    private attrApi: ProductAttrApiService
  ) {
  }
  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): ProductAttribute | Observable<ProductAttribute> | Promise<ProductAttribute> {
    return this.attrApi.fetchItem(route.queryParams.id);
  }
}
